Code Quality Improvements - Best Practices Implementation#1
Code Quality Improvements - Best Practices Implementation#1madkoding wants to merge 20 commits intominusbot-org:stablefrom
Conversation
- Add scripts/lint.sh for unified linting across all skills - Add scripts/check-cicd.sh for pipeline verification
- Add .github/workflows/cicd.yml for multi-skill pipeline - Add .github/workflows/youtubetv.yml for skill-specific workflows - Implement dynamic matrix testing strategy - Add lint-all, test, documentation, security jobs
- Add logging_utils.py with shared logging system - Support for JSON and colored output formats - Environment-based configuration
- Add AES-256-GCM encryption for all secrets - Implement rate limiting with auth middleware - Restrict CORS to whitelist of allowed origins - Fix path traversal with robust validation - Use crypto.randomBytes() instead of Math.random() - Add command whitelist to shell tools - Restrict sandbox network to 'none' by default - Add HTTP URL whitelist and timeout Closes security vulnerabilities: CWE-312, CWE-79, CWE-22, CWE-346, CWE-338, CWE-306, CWE-78
security: Implement critical security fixes
There was a problem hiding this comment.
I don't think the .env.example file is necessary, since there are no .env files in the skills.
The skill environments are created dynamically for each user individually when a skill is configured or installed.
Also... this is serpapi config for chromecast skill?
There was a problem hiding this comment.
I don't think the .env.example file is necessary, since there are no .env files in the skills.
The skill environments are created dynamically for each user individually when a skill is configured or installed.
Also... this is serpapi config for ffmpeg?
There was a problem hiding this comment.
This test isn't actually testing the real skill; it's just mocking both the functionality and the result, so it's not viable.
| """ | ||
| Query the current YouTube app state on the device. | ||
|
|
||
| Returns | ||
| ------- | ||
| AppState | ||
|
|
||
| Raises | ||
| ------ | ||
| requests.HTTPError | ||
| Some Philips / MediaTek TVs return 403 until the app is launched. | ||
| """ |
There was a problem hiding this comment.
I don't think removing documentation from functions is a good idea.
There was a problem hiding this comment.
I think this is over-engineering; you don't really need to document the skill, do you?
At some point, I think it would be better to remove the built-in skills and have each one in a separate repository. What do you think?
There was a problem hiding this comment.
I don't think it's necessary; only the LLM sees this logging anyway.
| export const resetLoginAttempts = (ip: string, username: string) => { | ||
| const userKey = `${ip}:${username}`; | ||
| loginAttempts[userKey] = 0; | ||
| }; |
There was a problem hiding this comment.
It would be better to remove the entry to avoid memory leaks (in case of a DDoS attack with thousands of IPs).
delete loginAttempts[userKey]
or use a Map#remove(key: string)
| **Severity**: HIGH | ||
| **Affected Files**: `src/api/routes/user/files.routes.ts:54-84` | ||
|
|
||
| **Description**: File uploads are not validated, allowing upload of malicious files (webshells, scripts). | ||
|
|
||
| **Remediation**: Implement file type whitelist and virus scanning. |
There was a problem hiding this comment.
The files here can only be accessed or executed by sandboxed shells, unless the user chooses to manually run malicious files outside the sandbox.
| **Severity**: MEDIUM | ||
| **Affected Files**: `skills/youtubetv/scripts/dial.py:164` | ||
|
|
||
| **Description**: XML parsing without disabling external entities. | ||
|
|
||
| **Remediation**: Use secure XML parser configuration. |
| **Severity**: MEDIUM | ||
| **Affected Files**: Multiple error handlers | ||
|
|
||
| **Description**: Error messages expose system paths, stack traces, and internal details. | ||
|
|
||
| **Remediation**: Implement generic error messages in production. |
There was a problem hiding this comment.
The app runs by default in a docker container.
| - Email: security@minusbot.ai | ||
| - Report vulnerabilities via responsible disclosure program |
There was a problem hiding this comment.
redundant files: there are 3 that only talk about security patches.
This PR introduces comprehensive code quality improvements across all skills, following Python best practices and industry standards.
Changes
✅ Testing Infrastructure
✅ Logging System
logging_utils.pymoduleLOG_LEVELandJSON_LOGSprint()statements with proper logging✅ Documentation
LOGGING.mdusage guideCICD.mdpipeline documentationIMPROVEMENT_PLAN.mdwith current status✅ CI/CD Pipeline
✅ Code Quality
except Exception)✅ Dependencies & Config
pyproject.toml,requirements.txt,ruff.tomlfor youtubetv.env.examplefiles for all skillsModified Files
skills/youtubetv/scripts/wrapper.py- Logging integration, docstrings, refactoringskills/youtubetv/scripts/dial.py- Type hints updatesskills/youtubetv/scripts/ytv_dial.py- Simplified refactoringskills/chromecast/scripts/*- Type hintsskills/ffmpeg/scripts/*- Type hintsskills/serpapi/scripts/search.py- Type hintsTesting
All tests passing:
pytest skills/youtubetv/scripts/ -v # 19 passedAll lint checks passing:
bash scripts/lint.sh # All checks passed!Breaking Changes
None - all changes are backward compatible.